package searchtab.util;

import searchtab.search.textfile.SearchState;
import searchtab.views.SearchTabView;

public class Beeper {

    private SearchTabView searchTabView;

    public Beeper(SearchTabView searchTabView) {
        this.searchTabView = searchTabView;
    }

    public void beepIfRequierd(SearchState searchState) {
        boolean isBeep = true;
        if (searchState.getPreviousFilterText().length() > searchState.getFilterText().length()) {
            isBeep = false;
        }

        if (isBeep && searchState.isNoResults()) {
            searchTabView.getSite().getShell().getDisplay().beep();
        }
    }
}
